package edu.fsu.cs.SHPE;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.Log;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class VenueItemizedOverlay extends ItemizedOverlay<OverlayItem> {

	private final static String TAG = "SHPE.VenueItemizedOverlay";
	private Context context;

	private ArrayList<OverlayItem> venueOverlays  = new ArrayList<OverlayItem>();

	public VenueItemizedOverlay(Drawable marker, Context context) {
		super(boundCenterBottom(marker));
		this.context = context;
		//this.marker = marker;

		//item = new OverlayItem(location, "Name", "Address");


	}

	protected boolean onTap(int index)
	{
		Log.i(TAG, "Map Tapped index " + index);
		OverlayItem item = venueOverlays.get(index);
		
		AlertDialog.Builder dialog = new AlertDialog.Builder(context);
		dialog.setTitle(item.getTitle());
		dialog.setMessage(item.getSnippet());
		dialog.show();

		return true;
	}


	public void addOverlay(OverlayItem venue){
		venueOverlays.add(venue);
		populate();
	}


	@Override
	protected OverlayItem createItem(int i) {
		return venueOverlays.get(i);
	}

	@Override
	public int size() {
		return venueOverlays.size();
	}


}
